package nsg2;
import java.awt.Color;
import java.awt.Toolkit;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JWindow;


public class Loding extends JWindow implements Runnable {

	public static final int WIDTH = 455;
	public static final int HIGHT = 295;
	
	public static final int SWIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
	public static final int SHIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
	
	public JProgressBar bar;
	public JLabel label;
	private Main main;
	
	public Loding(){
		
		label = new JLabel( new ImageIcon("1.jpg"));
		label.setBounds(0, 0, WIDTH, HIGHT - 15);
		
		bar = new JProgressBar();
		
		bar.setStringPainted(true);
		bar.setBorderPainted(false);
		bar.setForeground(new Color(0,210,40));
		bar.setBackground( new Color(188,190,194));
		
		bar.setBounds(0, HIGHT - 15 , WIDTH, 15);
		
		this.add(label);
		this.add(bar);
		
		this.setLayout(null);
		this.setLocation((SWIDTH - WIDTH)/2,(SHIGHT - HIGHT)/2);
		
		this.setSize(WIDTH, HIGHT);
		this.setVisible(true);
		main = new Main();
		
	}
	
	public static void main(String[] args) {
		Loding d = new Loding();
		new Thread(d).start();
		
	}

	
	
	@Override
	public void run() {
		// TODO Auto-generated method stub
		for (int i = 0; i < 100; i++) {
			
			try {
				Thread.sleep(80);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
			bar.setValue(i);
			
		}
		
		this.dispose();
		main.mainFrame();
	}
	
	
}
